package san.java.inherit_07;

import java.util.Objects;

public class Person {
    protected String name;
    protected int sex;
    protected int age;

    public Person() {
        this.name = "";
        this.sex = 1;
        this.age = 18;
    }

    public Person(String name, int sex, int age) {
        this.name = name;
        this.sex = sex;
        this.age = age;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Person person = (Person) o;
        return sex == person.sex &&
                age == person.age &&
                Objects.equals(name, person.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, sex, age);
    }

    public void work() {
        System.out.println("working...");
    }

    public void showInfos() {
        System.out.printf("name: %s sex: %d age: %d\n", name, sex, age);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getSex() {
        return sex;
    }

    public void setSex(int sex) {
        this.sex = sex;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}
